﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DotNet.Random.String
{
    /// <summary>
    /// string类型 随机基类，继承于StringAbsRandService
    /// 有以下属性
    /// Count：随机产生的字符串长度
    /// JoinString：连接字符串
    /// </summary>
    public class StringRandService : DotNet.Random.Abstract.StringAbsRandService
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="StringRandService" /> class.
        /// </summary>
        /// <param name="count">The count.</param>
        /// <param name="join">The join.</param>
        public StringRandService(int count, string join = "")
        {
            this.Count = count;
            this.JoinString = join;
        }

        /// <summary>
        /// Gets or sets the count.
        /// 随机产生的字符串长度
        /// </summary>
        /// <value>
        /// The count.
        /// </value>
        public int Count { get; set; }

        /// <summary>
        /// Gets or sets the join string.
        /// 连接字符串
        /// </summary>
        /// <value>
        /// The join string.
        /// </value>
        public string JoinString { get; set; }

        /// <summary>
        /// Rands this instance.
        /// 抽象方法rand，由实现类重写
        /// </summary>
        /// <returns>
        /// 返回string类型
        /// </returns>
        public override string Rand()
        {
            var res = this.Build.Rand(this.Serial, this.Count);
            var str = string.Join(this.JoinString, res);
            return str;
        }
    }
}
